<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <script>
    // const ary = [{a: 6}, {a: 1}, {a: 5}, {a: 2}];
    // const getResult = (ary) => {

    //   const filterResult = ary.filter(obj => obj.a >= 2);

    //   const mapResult = filterResult.map(obj => obj.a = obj.a.toString()).reverse();

    //   const reduceResult = mapResult.reduce((acc, cur) => acc + cur);

    //   return reduceResult;
    // }
    // console.log(getResult(ary))

    function deepClone(obj){
	if (typeof obj !== 'object' || obj === null) {
		return obj;
  }
  const newObj = Array.isArray(obj) ? [] : {}
  
  for( var key in obj ){
		if( typeof obj[key] == 'object' ){
			newObj[key] = deepClone(obj[key]);
		}else{
			newObj[key] = obj[key];
		}
	}
	return newObj;
}

const obj = {
   arr: [
     {
        key1: {
           name1: 1,
           name2: 2,
        },
        key2: 'value',
     },
   ],
   string: 'value',
}
console.log(obj)
console.log(deepClone(obj));
  </script>
</body>
</html>